{include file="public/header" /}
<link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css" />
<style>
    .bbbmmm{
        margin-top: 330px;
    }
    #container{
        height: 350px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        {if $type == 1}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">负责人：</label>
                            <div class="layui-input-block">
                                <input type="text" name="info_designer" placeholder="写什么就展示什么" class="layui-input ">
                            </div>
                        </div>
                        {/if}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">情况说明：</label>
                            <div class="layui-input-block">
                                <input type="text" name="info_info" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="image_1">
                            <label class="layui-form-label">现场照片：</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="info_img" id="photo" lay-verify="image">
                                <div id="uploader" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker"></div>
                                            <p>或将图片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {if $type == 1}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择分类：</label>
                            <div class="layui-input-block">
                                <select name="info_t_id"  lay-search="" lay-filter="types" id="types" lay-verify="required">
                                    <option value="">---- 请选择分类 ----</option>
                                    {foreach name="types" item="t"}
                                    <option value="{$t.t_id}" >{$t.t_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择品牌：</label>
                            <div class="layui-input-block">
                                <select name="info_pp_id"  lay-search="" lay-filter="pps" id="type_pps" lay-verify="required">

                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择门店：</label>
                            <div class="layui-input-block">
                                <select name="info_s_id"  lay-search="" lay-verify="required" id="type_sss" lay-verify="required">

                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择装饰城：</label>
                            <div class="layui-input-block">
                                <select name="info_p_id"  lay-search="" lay-verify="required">
                                    {foreach name="ps" item="v"}
                                    <option value="{$v.p_id}" >{$v.p_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {else /}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">关联设计师：</label>
                            <div class="layui-input-block">
                                <select name="info_user_id" lay-search=""  lay-verify="required">
                                    <option value="">请选择设计师</option>
                                    {foreach name="users2" item="v"}
                                    <option value="{$v.user_id}">{$v.user_d_name}({$v.user_phone})({$v.user_d_company})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {/if}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">订单金额</label>
                            <div class="layui-input-block">
                                <input type="number" placeholder="订单金额" value="0" name="info_money" maxlength="11" class="layui-input" lay-verify="number" >
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">排序值</label>
                            <div class="layui-input-block">
                                <input type="number" placeholder="值越大越靠前" value="1" name="info_sort" maxlength="11" class="layui-input" lay-verify="number" >
                            </div>
                        </div>
                        <input type="hidden" name="type" value="{$type}" />
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">添加
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    var n = wk.uploads({num:20,type:'png,jpg,jpeg',url:"{:url('admin/upload/upload')}"}); //图片
    function imgDel(e,obj){
        wk.uploads_del(e,obj,n); // 删除
    }
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('orderAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(types)', function(data){
            $.ajax({
                url:"{:url('admin/Store/getDatas')}",
                dataType:"json",
                data:'t_id=' + data.value,
                type:'post',
                success:function(res){
                    var opt = '';
                    $.each(res.msg,function(key,vo){
                        opt = opt+"<option value="+vo.pp_id+">"+vo.pp_name+"</option>";
                    });
                    $("#type_pps").empty();
                    $("#type_sss").empty();
                    $("#type_pps").append('<option value="">---- 请选择品牌 ----</option>');
                    $("#type_pps").append(opt);
                    form.render('select');
                }
            })
        });
        form.on('select(pps)', function(data){
            $.ajax({
                url:"{:url('admin/Cases/getDatas')}",
                dataType:"json",
                data:'pp_id=' + data.value,
                type:'post',
                success:function(res){
                    var opt = '';
                    $.each(res.msg,function(key,vo){
                        opt = opt+"<option value="+vo.s_id+">"+vo.s_name+"</option>";
                    });
                    $("#type_sss").empty();
                    $("#type_sss").append(opt);
                    form.render('select');
                }
            })
        });
    });
</script>
</body>
</html>